﻿<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Demo</title>
    <link href="~/Content/idangerous.swiper.css" rel="stylesheet" />
    <style>
        .device {
            width: 100%;
            height: 100%;
        }

        .swiper-container {
            height: 100%;
        }

        .banner {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <div class="device">
        <div class="swiper-container">
            <div class="swiper-wrapper">
            </div>
        </div>
        <div class="pagination"></div>
    </div>
    <script src="~/Scripts/jquery-3.2.0.min.js"></script>
    <script src="~/Scripts/idangerous.swiper.js"></script>
    <script>

        $(function () {

            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null)
                    return unescape(r[2]);
                return null;
            }
            
            function getAdvertImages() {
                $.ajax({
                    url: "/Home/GetAdvertImages",
                    type: "post",
                    data: { FCorpID: getQueryString("FCorpID") },
                    dataType: "json",
                    success: function (res) {
                        if (res.status == 1) {
                            var html = "";
                            var mImgUrl = res.ImgUrl;
                            var images = res.data[0].FImgUrl.split(",");
                            for (var i = 0; i < images.length; i++) {
                                html += '<div class="swiper-slide"><img class="banner" src="' + mImgUrl + images[i] + '" /></div>';
                            }
                            $(".swiper-wrapper").html(html);

                            //轮播图
                            var mySwiper = new Swiper('.swiper-container', {
                                pagination: '.pagination',
                                loop: true,
                                autoplay: 20000,
                                speed: 300,
                                grabCursor: true,
                                paginationClickable: true
                            });
                        }
                    }
                });
            }

            getAdvertImages();
        });
    </script>
</body>
</html>
